<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <!--标准mui.css-->
    <!-- <link rel="stylesheet" href="__PUBLIC__/Css/css/mui.min.css" /> -->
    <style>body{background-color: #FFF;}</style>
    <script src="/Public/js/mui.min.js"></script>
    <!--标准muiEND-->
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Css/wx_login.css?1">

    <script src="//libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
    <title>登录</title>

    <script>

         $(function(){
             wx.miniProgram.getEnv(function(res) {
                 if(!(res.miniprogram)) {
                     $('.showzc').css('display','none')
                 }
             })
         })


        function getCode() {

            var mobile = $('#mobile').val();

            var image_code = $('#image_code').val();
            var reg_mobile = /^(1(([357][0-9])|(47)|[8][0-9]))\d{8}$/;
            var reg_imagecode = /^[a-zA-Z0-9]{4}$/;
            if (!reg_mobile.test(mobile)) {
                // $('#error').html('请填写正确的手机号');
                alert('请填写正确的手机号');
                return false;
            }
            if (!reg_imagecode.test(image_code)) {
                $('#error').html('请填写正确的图片验证码');
                alert('请填写正确的图片验证码');
                return false;
            }

            //首次调用add函数
            $.ajax({
                type: "post",
                url: "/index.php/Users/sendMsg",
                data: {mobile: mobile, image_code: image_code},
                dataType: "json",
                success: function (data) {
                    if (data.status == false) {
                        $('#error').html(data.msg);
                        $('#error').css('display', 'block');
                    } else {
                        //$('#code').val(data.msg);
                        $('#error').css('display', 'none');
                        add();
                        $('#verify_image').attr("src", "__CONTROLLER__/verify" + Math.random());
                    }
                }
            });
        }

        var timerc = 60; //全局时间变量（秒数）
        function add() { //加时函数
            if (timerc == 0) {
                $('#getCodeBtn2').css('display', 'none');
                $('#getCodeBtn').css('display', 'block');
                $("#getCodeBtn").html('重新获取');
                timerc = 60;
                return false;
            }
            if (timerc <= 60 && timerc > 0) {
                timerc--; //时间变量减1
                $("#getCodeBtn").css('display', 'none');
                $("#getCodeBtn2").html(Number(parseInt(timerc % 60 / 10)).toString() + (timerc % 10) + '秒后获取');
                $('#getCodeBtn2').css('display', 'block');
                setTimeout("add()", 1000);
            }
            ;
        };

        function checkMobile() {
            var mobile = $('#tel').val();
            var reg_mobile = /^(1(([357][0-9])|(47)|[8][0-9]))\d{8}$/;
            if (mobile == '') {
                // $('#tel').val('请输入您的手机号码');
            } else if (!reg_mobile.test(mobile)) {
                alert('请填写正确的手机号')
                // $('#error').html('请填写正确的手机号');
            } else {
                $('#error').html('');
            }
        }

        function checkname() {
            var name = $('#name').val();
            if (name == '') {

                // $('#error').html('请填写输入您的姓名');
                alert('请填写输入您的姓名');

            } else {
                $('#error').html('');

            }


        }

        function checkForm() {
            var mobile = $('#tel').val();

            var code = $('#code').val();

            var reg_code = /^[0-9]{6}$/;
            var reg_mobile = /^(1(([357][0-9])|(47)|[8][0-9]))\d{8}$/;
            $('#error').html('');

            if (!reg_mobile.test(mobile)) {
                // $('#error').html('请填写正确的手机号');
                alert("请填写正确的手机号")
                return false;
            } else {

                tj();
            }

            return false;
        }

        $(function () {
            $('input').focus(function () {
                $(this).css('color', '#000');
            });
        });

        function tj() {
            $.ajax({
                type: "POST",
                url: "__CONTROLLER__/doLogin",

                cache: false,
                //dataType:json,
                data: $('#tab').serialize(),

                success: function (data) {

                    switch (data) {
                        case '0':
                            alert('登录成功');
                            window.location.href = "__CONTROLLER__/index/id/1";

                            break;
                        case '1':
                            // $('#error').html('用户或密码错误');
                            alert('用户或密码错误');
                            $('#code').val('');
                            $('#bvcode').attr("src", "__CONTROLLER__/verify/" + Math.random());
                            break;
                        case '3':
                            // $('#error').html('请输入正确的验证码信息');
                            alert('请输入正确的验证码信息');
                            $('#code').val('');
                            $('#bvcode').attr("src", "__CONTROLLER__/verify/" + Math.random());
                            break;
                        default:
                            alert(1 + data);
                    }

                }
            });
        }
    </script>
    <style>
        .btn_yanzheng1 img {
            float: right;
            margin-right: 3%;

        }
        .register{
            top:50px;
        }
        .blogo{
            margin-top: 80px;
            margin-left: 30px;
        }
        .blogo h4{
            color:#000;

        }
        .blogo p{
            color:#797979;
            font-size: 14px;
            /* margin-top: -20px; */
        }
        .tabs{
            padding:30px;
        }
        .reg input{
            width: 100%;
            /* border: 1px solid gray; */
        }
        .zhuce {
            height: 45px;
            position: relative;
            line-height: 45px;
        }
        .zhuce a {
            position: absolute;
            right: 30px;
            text-decoration: none;
            color: #000;
            out-line: none;
            -webkit-tap-highlight-color: rgba(255, 255, 255, 0);
            -webkit-user-select: none;
            -moz-user-focus: none;
            -moz-user-select: none;
        }
        .blogo{
            margin-top: 0;
        }
        .vertify {
            width: 50%!important;
            font-size: 14px!important;
        }
        .reg img {
            margin-left: 0;
        }
    </style>
</head>

<body style="max-width:100%; max-height:100%;">
<div class="zhuce">
    <a href="/index.php?s=/Index/register" class="showzc" style="display: block;">注册</a>
</div>
<div class="blogo">
    <h4>密码登录</h4>
    <p>欢迎登录小易出行-乘客端</p>
    <!-- <img src="__PUBLIC__/xiaoyi.png" alt=""> -->
</div>
<!--<div class="top2">修改个人信息</div>-->
<div class="tabs">
    <form action="" method="post" id="tab">
        <!-- <input type="hidden" name="code" value="">
        <input type="hidden" name="url" id="url" value="Orders/stepOne"> -->
        <!--<div class="youhui">★微信支付立减20元★</div>-->
        <div class="reg_conText">
            <div class="reg">

                <input type="tel" name="tel" id="tel" style="color:#ccc;margin-left: 0" maxlength="11" value="{$user['tel']}"
                       onblur="checkMobile()"  placeholder="手机号" />

            </div>
            <div class="reg">

                <input type="password" name="apppwd" id="apppwd" style="color:#ccc;margin-left: 0" maxlength="11" value=""
                       onblur=""  placeholder="登录密码" />

            </div>
            <div class="reg">
                <input class="vertify" type="text" name="code" id="code" style="width:40%;color:#ccc;margin-left: 0"
                       value="请先输入图片验证码" maxlength="4" onclick="if(this.value=='请先输入图片验证码'){this.value=''}">
                <div class="btn_yanzheng1" id="getCodeBtn3"><img id="bvcode" src="__CONTROLLER__/verify"
                                                                 onclick="this.src=this.src+'&'+Math.random()"
                                                                 width="100px;"></div>

            </div>
            <!--  <div class="reg">
                <img src="/Public/images/tubiao_072.png" style="margin-top:5px;">
                <input type="tel" name="verify_code" id="code" style="color:#ccc;" value="请输入验证码" maxlength="6" onclick="if(this.value=='请输入验证码'){this.value=''}">
                <div class="btn_yanzheng" id="getCodeBtn" onclick="getCode()">获取验证码</div>
                        <div class="btn_yanzheng" id="getCodeBtn2" style="display:none"></div>
                <div class="string2"></div>
            </div>-->
        </div>
        <div class="register">
            <!-- <div id="error" class="login" style="margin-top:0;"></div> -->
            <br>
            <div class="regist_now" onclick="checkForm()" style="width:90%;border-radius: 50px">登录</div>
        </div>
    </form>
</div>

</body>
</html>